﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EnvironmentManagerSystem.BLL;
using EnvironmentManagerSystem.MODE;

namespace EnvironmentManagerSystem
{
    public partial class AddMainBasicData : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnOk_Click(object sender, EventArgs e)
        {
            if (txtMainKindName.Text == string.Empty)
            {
                Jscript.Alert("类别名称不能为空", this);
                return;
            }
            if (txtMainKindName.Text.Length > 25)
            {
                Jscript.Alert("类别名称不能大于25个字", this);
                return;
            }
            if (txtMainKindMemo.Text.Length > 25)
            {
                Jscript.Alert("类别名称不能大于250个字", this);
                return;
            }
            BasicDataMainData model = new BasicDataMainData();
            model.DataKindName = txtMainKindName.Text.Trim();
            model.DataKindMEMO = txtMainKindMemo.Text.Trim();
            if (BasicData.InsertMainBasicData(model) > 0)
            {
                Response.Write("<script>alert('添加成功');window.parent.art.dialog.list['添加大类'].close();</script>");
            }
            else
            {
                Jscript.Alert("添加失败,请检查数据库!", this);
            }
        }

        #region 按钮(取消)(x)
        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Write("<script>window.parent.art.dialog.list['添加大类'].close();</script>");
        }
        #endregion

    }
}
